package com.iphanta.community.common.config;

import com.iphanta.community.common.RequestIdInterceptor;
import com.iphanta.community.common.AuthorizationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

/**
 * @author 墨声 E-mail: zehong.hongframe.huang@gmail.com
 * create time: 3/7/22 6:31 PM
 */
@Configuration
public class WebMvcConfig  implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer {
    @Autowired
    private RequestIdInterceptor requestIdInterceptor;

    @Autowired
    private AuthorizationInterceptor authorizationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(requestIdInterceptor).addPathPatterns("/**");
        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**").excludePathPatterns("/community/user/register");
    }
}

